﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HMS.PL.Forms
{
    public partial class Import : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {          
            if ((fileupload1.PostedFile != null) && (fileupload1.PostedFile.ContentLength > 0))
            {
                string fn = System.IO.Path.GetFileName(fileupload1.PostedFile.FileName);
                string SaveLocation = Server.MapPath("..\\Excel") + "\\" + fn;
                try
                {
                    fileupload1.PostedFile.SaveAs(SaveLocation);                   
                    //Response.Write("The file has been uploaded." + fileupload1.PostedFile.FileName);
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                    //Note: Exception.Message returns a detailed message that describes the current exception. 
                    //For security reasons, we do not recommend that you return Exception.Message to end users in 
                    //production environments. It would be better to put a generic error message. 
                }
            }
            else
            {
              //  Response.Write("Please select a file to upload.");
            }
        }

    }
}